﻿@{
    ViewData["Title"] = "租户管理";
}
<div class="layui-layout layui-layout-admin">
    <form class="layui-form" action="" lay-filter="val-filter">
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">租户类型</label>
                <div class="layui-input-inline">
                    <input type="radio" name="tenantType" value="0" title="ID隔离">
                    <input type="radio" name="tenantType" value="1" title="库隔离">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">租户名称</label>
                <div class="layui-input-inline">
                    <input type="hidden" name="id" value="0">
                    <input type="hidden" name="orgId" value="0">
                    <input type="hidden" name="userId" value="0">
                    <input type="text" name="name" autocomplete="off" lay-verify="required" class="layui-input">
                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">租户类型</label>
                <div class="layui-input-inline">
                    <input type="text" name="adminAccount" autocomplete="off" lay-verify="required" class="layui-input">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">联系电话</label>
                <div class="layui-input-inline">
                    <input type="text" name="phone" autocomplete="off" lay-verify="required" class="layui-input">
                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">邮箱</label>
                <div class="layui-input-inline">
                    <input type="text" name="email" autocomplete="off" lay-verify="required" class="layui-input">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">排序</label>
                <div class="layui-input-inline">
                    <input type="number" value="100" lay-affix="number" name="orderNo" autocomplete="off" class="layui-input">
                </div>
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">数据库类型</label>
            <div class="layui-input-block">
                <select name="dbType">
                    <option value="0">MySql</option>
                    <option value="1">SqlServer</option>
                    <option value="2">Sqlite</option>
                    <option value="3">Oracle</option>
                    <option value="4">PostgreSQL</option>
                    <option value="5">Dm</option>
                    <option value="6">Kdbndp</option>
                    <option value="7">Oscar</option>
                    <option value="8">MySqlConnector</option>
                    <option value="9">Access</option>
                    <option value="10">OpenGauss</option>
                    <option value="11">QuestDB</option>
                    <option value="12">HG</option>
                    <option value="13">ClickHouse</option>
                    <option value="14">GBase</option>
                </select>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">连接字符串</label>
            <div class="layui-input-block">
                <input type="text" name="connection" autocomplete="off" lay-verify="required" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">备注</label>
            <div class="layui-input-block">
                <textarea name="remark" class="layui-textarea"></textarea>
            </div>
        </div>
    </form>
</div>

@section scripts {
    <script type="text/javascript">
        var app = {};
        layui.use(['http', 'toast'], function () {
            var form = layui.form,
                http = layui.http, toast = layui.toast;
            //
            app.init = function () {
                var data = app.data || {};
                form.val('val-filter', data);
            }();
            app.save = function () {
                form.submit('val-filter', function (data) {
                    var postData = data.field
                    //
                    var url = postData.id == '0' ? '/api/sysTenant/add' : '/api/sysTenant/update'
                    http.post(url, postData).then((res) => {
                        if (res.code == 200) {
                            parent.layer.close(parent.layer.getFrameIndex(window.name));//关闭当前页
                            parent.layui.table.reload('lsttable');
                            toast.success({ message: '保存成功！' });
                        }
                        else {
                            layer.alert('保存失败，错误信息:' + res.message, { icon: 2 });
                        }
                    });

                    return false;
                });
            }
        })
    </script>
}
